/*
 * @Author: soso
 * @Date: 2022-03-14 15:01:02
 * @LastEditTime: 2022-03-14 15:04:23
 * @LastEditors: Please set LastEditors
 * @Description: 日志配置
 * @FilePath: /gomeshcli/sconfig/log.go
 */

package sconfig

import (
	"log"
	"os"
	"path/filepath"

	"gitee.com/kimsoso/go-utils/utils"
)

func setLog() {
	var outputFile *os.File
	if SConfig.Log {
		file := filepath.Join(utils.GetCurrentAbPath(), "gms.log")
		logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, os.ModePerm)
		if err != nil {
			panic(err)
		}
		outputFile = logFile
	} else {
		outputFile = os.Stdout
	}

	log.SetOutput(outputFile)
	log.SetPrefix("[gomeshcli]")
	log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC)
}
